package slstone.quote.writtenEstimate.dao;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

import slstone.quote.writtenEstimate.dao.pojo.WrittenEstimate;

public class WrittenEstimateDao
{

	public void saveWrittenEstimate(List<WrittenEstimate> saveList)
	{	
			// DB세션
			Configuration config = new Configuration();
			SessionFactory sessionFactory = config.configure().buildSessionFactory();
			Session session = sessionFactory.openSession();
			Transaction transatcion = session.beginTransaction();
				
			for(int i = 0; i<saveList.size(); i++)
			{
				session.save(saveList.get(i));
			
			}
			
			
			try
			{
				session.flush();
				session.clear();
				transatcion.commit();		
			}
			catch(Exception e)
			{				
				transatcion.rollback();	
			}
			finally
			{				
				session.close();
				sessionFactory.close();					
			}
					
		
	}

}
